<?php
declare(strict_types=1);
namespace App\Controller\Notify;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Annotation\Controller;
use Service\DeliveryService\ExpressDeliveryService;
use Hyperf\Di\Annotation\Inject;

/**
 * 快递投递和用户取件通知
 * 
 * @Controller(prefix="/expressdelivery")
 */
class ExpressDeliveryController extends AbstractController
{
    /**
     * @Inject()
     * @var ExpressDeliveryService
     */
    protected $expressDeliveryService;
    
    /**
     * 回调接口地址
     * @RequestMapping(path="notify/{company}", methods="post")
     */
    public function deliverynotify(RequestInterface $request,ResponseInterface $response,$company)
    {
        $data=$request->getParsedBody();  
        return $this->expressDeliveryService->Delivery($company, $data, $response);
    }
    
    /**
     * 获取快递手机号码
     * @RequestMapping(path="getinfo/{company}", methods="post")
     */
    public function deliverygetinfo(RequestInterface $request,ResponseInterface $response,$company)
    {
        $data=$request->input('expressNo', '');
        return $this->expressDeliveryService->getinfo($data);
    }
}